package com.ls.aop.chain;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ChainClient {

	class Handler1 extends Handler{
		private Logger logger = LoggerFactory.getLogger(this.getClass());
		public Handler1(Chain chain) {
			super(chain);
		}

		@Override
		protected void beforeProcess() {
			logger.info("handler 1 before process");
		}

		@Override
		protected void afterProcess() {
			logger.info("handler 1 afterProcesss");
		}
		
	}
	
	class Handler2 extends Handler{
		private Logger logger = LoggerFactory.getLogger(this.getClass());
		public Handler2(Chain chain) {
			super(chain);
		}

		@Override
		protected void beforeProcess() {
			logger.info("handler 2 before process");
		}

		@Override
		protected void afterProcess() {
			logger.info("handler 2 afterProcesss");
		}
		
	}
	
	public static void main(String[] args) {
		Chain chain = new Chain();
		Handler h1=  new ChainClient().new Handler1(chain);
		Handler h2=  new ChainClient().new Handler2(chain);
		Handler h3=  new ChainClient().new Handler1(chain);
		chain.add(h1);
		chain.add(h2);
		chain.add(h3);
		chain.process();
	}
	
}
